<h1><%= @movie.title %></h1>


<div>
<% if @poster_urls[@movie.id] %>
<div style="display: inline-block;">
  <img height="303" width="195" style="padding-left: 10px; margin-top: 10;" src="<%= @poster_urls[@movie.id] %>" />
</div>
<% end %>

<div style="display: inline-block; border: 1px solid gray; height: 291px; width: 400px; padding: 5px; vertical-align: top;">
	<table>
		<tr>
			<th style="text-align: left">Movie ID:</th>
			<td style="padding-left: 1em;"><%= @movie.id %></td>
		</tr>
		<tr>
			<th style="text-align: left">Title:</th>
			<td style="padding-left: 1em;"><%= @movie.title %></td>
		</tr>
		<tr>
			<th style="text-align: left">Release Year:</th>
			<td style="padding-left: 1em;"><%= @movie.year %></td>
		</tr>
		<tr>
			<th style="text-align: left">Average Rating:</th>
			<td style="padding-left: 1em;"><%= @movie.rating_avg.round(3) %> (<%= @movie.rating_count %>)</td>
		</tr>
		
		<tr>
			<th style="text-align: left">TMDB ID:</th>
			<% if @movie.tmdbid > 0 %>
			<td style="padding-left: 1em;"><a href="https://www.themoviedb.org/movie/<%= @movie.tmdbid %>" target="_new"><%= @movie.tmdbid %></a></td>
			<% else %>
			<td style="padding-left: 1em;">No data found</td>
			<% end %>
		</tr>
	</table>

	<%= column_chart(@freq_data, library: {:chart => {:width => 240, :height => 200}, :title => {:text => 'Rating Distribution'} }) %>
</div>
</div>
<div>
	<h2 style="padding-top: 12px;">Similar Movies - kNN</h2>

	<% @similarmovies.each do |sm| %>
	<div style="float: left; border: 1px solid grey;">
		<table>
			<tr><th><a href="/movies/<%= sm.id %>"><%= sm.title%></a></th></tr>
			<tr><td>
				<% if @poster_urls[sm.id].nil? %>
				<a href="/movies/<%= sm.id %>"><%= image_tag "notfound.jpg", alt: 'Image Not Found', height: 303, width: 195, style: 'padding: 10px' %></a>
				<% else %>
				<a href="/movies/<%= sm.id %>"><img height="303" width="195" style="padding: 10px;" src="<%= @poster_urls[sm.id] %>" /></a>
				<% end %>
			</td></tr>
		</table>
	</div>
	<% end %>
</div>
<div style="display: block; clear: both;">&nbsp</div>
<div>
	<h2 style="padding-top: 12px;">Similar Movies - SVD</h2>

	<% @similarmovies_svd.each do |sm| %>
	<div style="float: left; border: 1px solid grey;">
		<table>
			<tr><th><a href="/movies/<%= sm['movie'].id %>"><%= sm['movie'].title %></a> (<%= '%1.3f' % sm['similarity'] %>)</th></tr>
			<tr><td>
				<% if @poster_urls[sm['movie'].id].nil? %>
				<a href="/movies/<%= sm['movie'].id %>"><%= image_tag "notfound.jpg", alt: 'Image Not Found', height: 303, width: 195, style: 'padding: 10px' %></a>
				<% else %>
				<a href="/movies/<%= sm['movie'].id %>"><img height="303" width="195" style="padding: 10px;" src="<%= @poster_urls[sm['movie'].id] %>" /></a>
				<% end %>
			</td></tr>
		</table>
	</div>
	<% end %>
</div>
